#include "DXSprite.h"

DXSprite::DXSprite (void)
{
}

DXSprite::DXSprite (LPDIRECT3DDEVICE9 RenderDevice, LPD3DXSPRITE SpriteDevice, LPCWSTR File, D3DXVECTOR3 Pos)
{
	SetSpriteDevice(SpriteDevice);
	LoadSprite(RenderDevice, File);
	SetPosition(Pos);
}

DXSprite::~DXSprite (void)
{
	if (Sprite)
		Sprite->Release();
}

BOOL DXSprite::LoadSprite (LPDIRECT3DDEVICE9 RenderDevice, LPCWSTR File)
{
	BOOL Success = TRUE;

	if (FAILED(D3DXCreateTextureFromFile(RenderDevice, File, &Sprite)))
		Success = FALSE;
	if (!Sprite)
		Success = FALSE;
	
	return Success;
}

void DXSprite::SetSpriteDevice (LPD3DXSPRITE SpriteDevice)
{
	Device = SpriteDevice;
}

void DXSprite::SetPosition (D3DXVECTOR3 & Pos)
{
	Position = Pos;
}

void DXSprite::Draw (void)
{
	if (Sprite)
		Device->Draw(Sprite, NULL, NULL, &Position, COLOR(255, 255, 255, 255));
}